-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use nvim-treesitter define_modules to attach/detach to buffers #42
fix: use nvim-treesitter define_modules to attach/detach to buffers #42
Conversation
@@ -140,34 +140,15 @@ nvim_biscuits.decorate_nodes = function(bufnr, lang) | |||
end | |||
end | |||
|
|||
nvim_biscuits.setup = function(user_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this function below nvim_biscuits.BufferAttach
definition so that we can use it inside the setup.
local attached_buffers = {} | ||
nvim_biscuits.BufferAttach = function(bufnr) | ||
bufnr = bufnr or vim.api.nvim_get_current_buf() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bufnr
should now be passed in.
if attached_buffers[bufnr] then return end | ||
|
||
attached_buffers[bufnr] = true | ||
|
||
local lang = ts_parsers.get_buf_lang(bufnr):gsub("-", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lang
should now be passed in.
local toggle_keybind = config.get_language_config(final_config, lang, | ||
"toggle_keybind") | ||
if toggle_keybind ~= nil and | ||
not config.get_language_config(final_config, lang, "disabled") then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now implemented in the is_supported
function below
@@ -2,7 +2,3 @@ | |||
|
|||
highlight default BiscuitColor ctermfg=gray guifg=gray | |||
|
|||
augroup NVIM_BISCUITS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need this.
Awesome. This looks great. |
Fixes #41
By changing the way nvim-biscuits attaches to the buffer (using the nvim-treesitter define_modules functionality)
it seems to have resolved the issue I was experiencing when opening a file via telescope.
I suspect that the BufEnter autocmd was triggering too early causing the buffer to not complete have been registered with treesitter and so the language was empty string.